var t = getApp();

Page({
    data: {
        checked: !1,
        showExample: !1,
        showAgreement: !1,
        showTips: !1,
        showUpload: !1,
        progress: "98%",
        tranImg: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/example.png",
        kFootshow: !0
    },
    onLoad: function(t) {
        this.getData();
    },
    tabrshowbtn: function(t) {
        t.detail && this.setData({
            kFootshow: !1
        });
    },
    checkboxinp: function(t) {
        console.log(t);
        var e = t.detail;
        this.setData({
            checked: e
        });
    },
    goband: function() {
        wx.navigateTo({
            url: "/packageE/others/rank/rank"
        });
    },
    goLog: function() {
        wx.navigateTo({
            url: "/packageE/others/log/log"
        });
    },
    tap_showExample: function() {
        this.setData({
            showExample: !this.data.showExample
        });
    },
    posterClose: function() {
        this.setData({
            showExample: !1
        });
    },
    posterClose_b: function() {
        console.log("执行"), this.setData({
            showAgreement: !1
        });
    },
    tap_showAgreement: function() {
        this.setData({
            showAgreement: !this.data.showExample
        });
    },
    tap_showTips: function() {
        this.setData({
            showTips: !1
        });
    },
    tapUpload: function() {
        if (1 != this.data.set.is_open || this.data.checked) {
            var e = this;
            wx.chooseImage({
                count: 1,
                sizeType: [ "original", "compressed" ],
                sourceType: [ "album", "camera" ],
                success: function(o) {
                    var a = o.tempFilePaths;
                    console.log(o);
                    var s = Number(o.tempFiles[0].size);
                    s < 1024 ? s = Number(s).toFixed(2) + "b" : s >= 1024 && (s = Number(s / 1024).toFixed(2) + "kb"), 
                    e.setData({
                        size: s,
                        showUpload: !0,
                        tranImg: o.tempFilePaths[0]
                    });
                    var n = t.getNetAddresss("upload.uploadPic");
                    wx.uploadFile({
                        url: n,
                        filePath: a[0],
                        name: "file",
                        success: function(t) {
                            var o = t.data;
                            o = JSON.parse(o), console.log(o), e.uploadImg(o.data.img);
                        }
                    }).onProgressUpdate(function(t) {
                        e.setData({
                            progress: t.progress
                        });
                    });
                }
            });
        } else wx.showToast({
            title: "请勾选测肤协议",
            icon: "none",
            duration: 1e3
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        wx.showLoading({
            title: "加载中"
        });
        var e = this, o = t.getNetAddresss("plugin.skin-check.api.skin-check.index");
        t._getNetWork({
            url: o,
            success: function(t) {
                wx.hideLoading({
                    complete: function(t) {}
                });
                var o = t.data;
                if (console.log(o), 1 == o.result) {
                    e.setData({
                        set: o.data.set.treaty_data,
                        customizeName: o.data.customizeName,
                        rank_list: o.data.rank_list
                    });
                    try {
                        wx.setNavigationBarTitle({
                            title: o.data.customizeName
                        });
                    } catch (t) {
                        console.log(t);
                    }
                } else wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t), wx.hideLoading({
                    complete: function(t) {}
                });
            }
        });
    },
    uploadImg: function(e) {
        var o = this, a = t.getNetAddresss("plugin.skin-check.api.skin-check.skin-check");
        t._getNetWork({
            url: a,
            data: {
                img: e,
                is_check: o.data.checked ? 1 : 0
            },
            success: function(e) {
                var a = e.data;
                console.log(a), 1 == a.result ? t._isTextEmpty(a.data.checkAuth) ? (wx.navigateTo({
                    url: "/packageE/others/skin_result/skin_result?id=" + a.data.reportId
                }), o.setData({
                    showUpload: !1
                })) : wx.showToast({
                    title: a.data.checkAuth,
                    icon: "none",
                    duration: 1e3
                }) : t._isTextEmpty(a.data) ? t._isTextEmpty(a.data.checkAuth) ? o.setData({
                    showUpload: !1,
                    tranImg: !1,
                    showTips: !0,
                    checkAuth: !1
                }) : o.setData({
                    showUpload: !1,
                    tranImg: !1,
                    showTips: !0,
                    checkAuth: a.data.checkAuth
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1e3,
                    success: function() {
                        setTimeout(function() {
                            o.setData({
                                showUpload: !1,
                                tranImg: !1
                            });
                        }, 1e3);
                    }
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});